import pandas as pd
labour_force = pd. read_excel("Labor force data.xlsx")
labour_force.head()
| State | Labour Force Population | |
|---|---|---|
| 0 | NaN | NaN |
| 1 | Abia | 1.919458e+06 |
| 2 | Adamawa | 1.445800e+06 |
| 3 | Akwa Ibom | 3.217171e+06 |
| 4 | Anambra | 3.009646e+06 |
labour_force.drop(index=0,axis=0,inplace=True)
labour_force.head()
| State | Labour Force Population | |
|---|---|---|
| 1 | Abia | 1.919458e+06 |
| 2 | Adamawa | 1.445800e+06 |
| 3 | Akwa Ibom | 3.217171e+06 |
| 4 | Anambra | 3.009646e+06 |
| 5 | Bauchi | 1.825977e+06 |
labour_force.dtypes
State object Labour Force Population float64 dtype: object
import plotly.graph_objs as go
import plotly.express as px
import plotly.io as pio
fig = px.bar(labour_force, y = 'State', x = 'Labour Force Population ', orientation = 'h', color = 'Labour Force Population ', text = 'Labour Force Population ')
fig.update_traces(texttemplate='%{text:.2s}', textposition='outside')
fig.update_layout(uniformtext_minsize=8, uniformtext_mode='hide')
fig.update_layout(
title={
'text':"Labour Force Per State For Q1 in 2017",
'y':0.95,
'x':0.5,
'xanchor': 'center',
'yanchor': 'top'}, template = "seaborn", height = 900, width =900)
import json
nigeria_states = json.load(open("nigeria_geojson.geojson", "r"))
nigeria_states["features"][0]["properties"].keys()
dict_keys(['objectid', 'statecode', 'state', 'capcity', 'source', 'timestamp', 'globalid', 'shape_area', 'shape_len', 'geozone', 'cartodb_id', 'created_at', 'updated_at'])
state_id_map = {}
for feature in nigeria_states["features"]:
feature["id"] = feature["properties"]["statecode"]
state_id_map[feature["properties"]["state"]] = feature["id"]
labour_force["id"] = labour_force["State"].apply(lambda x: state_id_map[x])
fig = px.choropleth(labour_force, geojson=nigeria_states, locations='id', color='Labour Force Population ',scope = "africa", hover_name = "State", hover_data = ["State"])
fig.update_geos(fitbounds="locations", visible=False)
fig.show()